package com.example.demo.web.rest.controller;

import com.example.demo.client.evt.sysbasequery.QueryFeedbackEvt;
import com.example.demo.client.vm.sysbasequery.FeedbackVm;
import com.ffcs.oss.param.out.ServiceResp;
import com.ffcs.oss.param.vm.QueryPageVm;
import com.example.demo.service.FeedbackService;
import com.example.demo.web.rest.evt.IdEvt;
import com.example.demo.web.rest.evt.SaveFeedbackEvt;
import com.example.demo.web.rest.evt.SaveReplyFeedbackEvt;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 反馈管理
 * @Author zhengmf
 * @Date 2019/1/2  15:47
 */
@ApiModel(description ="反馈接口")
@RestController
@RequestMapping(value = "/api/feedback")
public class FeedbackController extends BaseController{

    @Autowired
    private FeedbackService feedbackService;

    @ApiOperation("保存反馈信息")
    @PostMapping(value = "/saveFeedback")
    public ServiceResp<Boolean> saveFeedback(@RequestBody @Validated SaveFeedbackEvt evt){
        Long id = feedbackService.saveFeedback(evt);
        logger.info("保存反馈信息,ID为" + id);
        return ServiceResp.getInstance(Boolean.class).success(true);
    }

    @ApiOperation("保存反馈回复信息")
    @PostMapping(value = "/saveReplyFeedback")
    public ServiceResp<Boolean> saveReplyFeedback(@RequestBody @Validated SaveReplyFeedbackEvt evt){
        Long id = feedbackService.saveReplyFeedback(evt);
        logger.info("保存反馈回复信息,ID为" + id);
        return ServiceResp.getInstance(Boolean.class).success(true);
    }

    @ApiOperation("删除反馈信息")
    @PostMapping(value = "/delFeedback")
    public ServiceResp<Boolean> delFeedback(@RequestBody @Validated IdEvt evt){
        feedbackService.updateStatus(evt);
        return ServiceResp.getInstance(Boolean.class).success(true);
    }

    @ApiOperation("反馈查询接口")
    @PostMapping("/queryFeedback")
    public ServiceResp<QueryPageVm<FeedbackVm>> queryFeedback(@RequestBody QueryFeedbackEvt evt){
        return baseQueryClient.queryFeedback(evt);
    }

}
